package arraylist;

import java.util.ArrayList;
import java.util.Scanner;

public class AraayList2 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("输入集合大小:");
        int count=scanner.nextInt();
        ArrayList <String>arrayList=new ArrayList<>(count);
        addElements( count, arrayList);
        printArray( arrayList);
        removeElements(arrayList);
        printArray(arrayList);

    }

    private static void printArray( ArrayList<String> arrayList) {
        for (int i = 0; i <arrayList.size(); i++) {
            String str= arrayList.get(i);
            System.out.println(str);
        }
    }

    private static void removeElements(ArrayList<String> arrayList) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入删除的元素:");
        String target=scanner.nextLine();
//        for (int i = 0; i < arrayList.size() ; i++) {
//            arrayList.remove(target);
//        }
        for (int i = 0; i <arrayList.size() ; i++) {
            if ("test".equals(target));
            i--;
        }
    }

    private static void addElements(int count,  ArrayList<String> arrayList) {
            Scanner scanner=new Scanner(System.in);
            System.out.println("请输入集合元素:");
        for (int i = 0; i <count ; i++) {
            String str= scanner.next();
            arrayList.add(str);
        }

    }

}
